<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<title>手机验证-{$tpshop_config['shop_info_store_title']}</title>
<meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
<meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
</head>
<style type="text/css">
.favorites_title ul li,.favorites .favorites_content .clearfix li{width:19.8%}
.favorites_title ul li, .favorites .favorites_content .clearfix li:last-child{border:0}
</style>
<body> 
<!-- 头部-s -->
<include file="User/header" />
<!-- 头部-e -->
<script src="__PUBLIC__/js/layer/layer.js"></script><!--弹窗js 参考文档 http://layer.layui.com/-->
<script src="__PUBLIC__/js/global.js"></script>
<script src="__PUBLIC__/js/pc_common.js"></script>
<link rel="stylesheet" href="__STATIC__/css/favorite.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/css/security_set.css"/>

<div class="wrap">
  <div class="bread_crumbs"> <a href="{:U('Home/User/index')}" class="crumbs_font">我的TPshop</a>&gt;<span class="color">优惠券</span></div>
  <!--菜单--> 
  <include file="User/menu" /> 
  <!--菜单-->     
  <!--侧边导航栏结束-->
    <div class="col_main">
  <div class="main security_passwd">
    <div class="themes_title">
      <h3>安全设置</h3>
    </div>
    <section class="security_passwd">
      <div class="wrapper-3">
        <div id="step" class="pub-step">
          <div class="steps-nav fixed ">
            <p class="step-nav step-nav-1 go">1.原手机<i></i></p>
            <p class="step-nav step-nav-2 go">2.新手机<i></i></p>
            <p class="step-nav step-nav-3 go">3.完成</p>
          </div>
          <form action="" method="post" onSubmit="return check_form();">
          <div id="stepBlock2" class="steps-con block-02">
            <div class="step-col fn-form captcha_row" data-fn-verify="">
              <ul style="display: block;" class="pub-ul verify-captcha-sms">
              <notempty name="user_info.mobile">
                <li> <span class="title">原手机：</span>
                  <div class="con verify-group">
                    <input type="text" class="it-01 verify-ctrl my_chkpwd" value="{$user_info['mobile']}" id="old_mobile" name="old_mobile" readonly="readonly"
                           style="cursor: not-allowed;color:#999" />
                    <span style="display: block" class="v-tips verify-tips" id="span_tips"> 
                    	<i class="icon" id="showForPwdtip"></i> 
                        <span class="txt" id="showForPwd"></span> 
                    </span> 
                  </div>
                </li>
              </notempty>
                <li> <span class="title">新手机：</span>
                  <div class="con verify-group">
                    <input type="text" class="it-01 verify-ctrl my_chkpwd" value="" id="new_mobile" name="mobile" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" />
                    <span style="display: block;" class="v-tips verify-tips"> <i class="icon" id="rightTip"></i> <span id="errorEmail" class="txt"></span> </span> </div>
                </li>
                <li> <span class="title">验证码：</span>
                  <div class="con verify-group">
                    <input type="text" class="msg-code ie-01 verify-ctrl left" name="code" id="new_code">&nbsp;&nbsp;
                    <input type="button" intervaltime="{$time}" value="获取验证码 " id="btnemailAuthCode2" onClick="sendCode(this,'new_mobile')" style="width:120px;"  />
                   </div>                   
                </li>                 
                <li>
                  <button class="btn_120 verify-ctrl" type="submit"> 下一步 </button>
                </li>
              </ul>
            </div>
          </div>
          </form>          
        </div>
      </div>
    </section>
  </div>
</div> 
</div>
 
<div style="clear: both;"></div>
<include file="User/footer" />

<script>

	// 表单提交验证
	function check_form()
	{
        var old_mobile = $('#old_mobile').val();		
        var new_mobile = $('#new_mobile').val();
        //原邮箱不为空的情况下 验证格式
        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
            if(!checkMobile(old_mobile)){
                layer.alert('原手机格式错误', {icon: 2});// alert('原手机格式错误');
                return false;
            }
        }
        if(!checkMobile(new_mobile)){
            layer.alert('新手机格式错误', {icon: 2});//alert('新手机格式错误');
            return false;
        }	
		
		if($.trim($('#new_code').val()) == '')	
		{
            layer.alert('验证码不能为空', {icon: 2});//alert('验证码不能为空');            
            return false;			
		}
		return true;
	}

    function sendCode(obj,input_id){
        var id = $(obj).attr('id');
        var input = $('#'+input_id).val();
        var old_mobile = $('#old_mobile').val();
        //原邮箱不为空的情况下 验证格式
        if(old_mobile != '' && typeof(old_mobile) != 'undefined'){
            if(!checkMobile(old_mobile)){
                layer.alert('原手机格式错误', {icon: 2});//alert('原手机格式错误');
                return false;
            }
        }
        if(!checkMobile(input)){
            layer.alert('手机号码格式错误', {icon: 2});//alert('手机号码格式错误');
            return false;
        }
        if(input_id == 'old_mobile')
            var url = "/index.php?m=Home&c=User&a=send_validate_code&step=1&type=mobile&send="+input;
        if(input_id == 'new_mobile')
            var url = "/index.php?m=Home&c=User&a=send_validate_code&step=2&type=mobile&send="+input;
        //发送验证码
        $.ajax({
            type : "GET",
            url  : url,
            dataType : 'json',
            error: function(request) {
                layer.alert('服务器繁忙, 请联系管理员!', {icon: 2});//alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(res) {
                if(res.status == 1){
                    jsInnerTimeout(id);
                }else{
                    layer.alert(res.msg,{icon: 2});//alert('发送失败');
                }
            }
        });
    }

    //倒计时函数
    function jsInnerTimeout(id)
    {
        var codeObj=$("#"+id);
        var intAs=parseInt(codeObj.attr("IntervalTime"));

        intAs--;
        codeObj.attr("disabled","disabled");
        if(intAs<=-1)
        {
            codeObj.removeAttr("disabled");
            codeObj.attr("IntervalTime",{$time});
            codeObj.val("获取验证码");
            return true;
        }

        codeObj.val(intAs+'s后再次获取');
        codeObj.attr("IntervalTime",intAs);

        setTimeout("jsInnerTimeout('"+id+"')",1000);
    }; 
</script>
</body>
</html>